﻿using System.Reflection;
using System.Web.Http;
using Abp.Application.Services;
using Abp.Configuration.Startup;
using Abp.Modules;
using Abp.WebApi;

namespace myu.Api
{
    [DependsOn(typeof(AbpWebApiModule), typeof(myuApplicationModule))]
    public class myuWebApiModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());



            //this.Configuration
            //   .Modules
            //   .AbpWebApi()
            //   .DynamicApiControllerBuilder
            //   .ForAll<IApplicationService>(Assembly.GetAssembly(typeof(myuApplicationModule)), "recruitment")
            //   .WithConventionalVerbs()
            //   .Build();


            Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
                .ForAll<IApplicationService>(typeof(myuApplicationModule).Assembly, "app")
                .Build();

            Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
        }



        /// <summary>
        /// 模块初始化之后
        /// </summary>
        public override void PostInitialize()
        {
            ////注册 路由规则
            this.Configuration.Modules.AbpWebApi().HttpConfiguration.Routes.MapHttpRoute(
                name: "RecruitWebApi",
                routeTemplate: "api/recruitment/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional });
        }
    }
}
